﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace ASoft.WPF
{
    [ValueConversion(typeof(byte), typeof(string))]
    public class ConverterOpenClose : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return ((byte)value == 1) ? "开" : "关";
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (byte)(string.Equals("开", value as string) ? 1 : 0);
        }
    }
}
